Ext.namespace('Divo');
Ext.namespace('Divo.app');

Divo.app.PriceReviewList = function() {
  /* ----------------------- private属性 ----------------------- */
  var gridEl = 'PriceReview-grid';
  var grid, form, selModel, toolbar, win;
  var data, sId;
  var fldTime, fldCode;
  /* ----------------------- private方法 ----------------------- */
  // 创建列表
  function createGrid() {
    var queryFlds = new Array();
    var searchFlds = new Ext.util.MixedCollection();
    queryFlds.push('name');
    var fldName = new Ext.form.TextField({
          name : 'name',
          id : gridEl + '-name',
          fieldLabel : '名称',
          allowBlank : true,
          width : 100

        });
    searchFlds.add('name', fldName);

    grid = new Divo.Base.GridView({
          remoteSort : true,
          gridId : gridEl,
          queryFlds : queryFlds,
          searchFlds : searchFlds,
          entityClassName : 'com.our.sys.project1.pojo.PriceReview',
          queryUrl : 'query_main/query_price_review',
          jsonId : 'id',
          recordPk : ["id"]
        });
  }

  // 刷新列表
  function reloadRecords() {
    grid.getStore().reload();
  }

  // 创建layout
  function createLayout() {
    toolbar = new Ext.Toolbar({
          items : [{
                xtype : "button",
                cls : "x-btn-icon",
                icon : "resources/img/g_rec_src.png",
                tooltip : "过滤数据",
                id : "tlb_FILTER",
                handler : toggleFilterBar
              }, {
                icon : "resources/img/g_rec_refresh.gif",
                text : "刷新",
                id : "tlb_REFRESH",
                handler : reloadRecords
              }]
        });
    var viewport = new Ext.Viewport({
          layout : 'border',
          items : [{
                layout : 'border',
                region : 'center',
                border : false,
                items : [{
                      layout : 'fit',
                      region : 'center',
                      border : false,
                      items : [grid]
                    }]
              }]
        });
    viewport.doLayout();
  }

  // 切换过滤查询工具条状态
  function toggleFilterBar() {
    grid.toggleFilterBar();
  }

  /* ----------------------- public方法 ----------------------- */
  return {
    /**
     * 初始化
     */
    init : function() {
      createGrid();
      createLayout();
      grid.getStore().load();
    }
  }
}();

Ext.onReady(Divo.app.PriceReviewList.init, Divo.app.PriceReviewList, true);